package score;

import java.util.Collection;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class ScoreSort {
    public static void main(String[] args) {
        Set<Student> set = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {

                int sum1 = o1.getShuxue() + o1.getYingyu() + o1.getYuwen();
                int sum2 = o2.getShuxue() + o2.getYingyu() + o2.getYuwen();
                System.out.println(o1.getName() + "---------" + sum1);
                return sum2 - sum1;
            }
        });
        set.add(new Student("张三1", 11, 26, 303));
        set.add(new Student("张三2", 12, 23, 323));
        set.add(new Student("张三3", 13, 22, 313));
        set.add(new Student("张三4", 14, 21, 353));
        System.out.println(set);
    }
}
